<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
 * @todo 关联汇款信息与银行账单
 *
 */
class RemittanceAndBankAccountsRels_model extends CI_Model{
    function get_All()
    {
		$this->db->where('IsDeled', 0); 
		$this->db->order_by("id", "desc"); 
        $query = $this->db->get('aitupu_RemittanceAndBankAccountsRels');   
		return $query;
    }
	
	function get_Id($Id)
    {
        $query = $this->db->get_where('aitupu_RemittanceAndBankAccountsRels', array('id' => $Id));
        return $query->row();
    }	
	
	function get_BelongRemittance($Remittance)
    {
		$this->db->where('IsDeled', 0); 
		$this->db->like('BelongRemittance', $Remittance); 
        $query = $this->db->get('aitupu_RemittanceAndBankAccountsRels'); 
        return $query;
    }	
	
	function get_BelongBankAccounts($BankAccounts)
    {
		$this->db->where('IsDeled', 0); 
		$this->db->like('BelongBankAccounts', $BankAccounts); 
        $query = $this->db->get('aitupu_RemittanceAndBankAccountsRels'); 
        return $query;
    }		
	
	function Del_BelongRemittance($Remittance)
	{
		$this->db->where('BelongRemittance', $Remittance); 
		$Data = array(
			'IsDeled'=>1
		);
		$this->db->update('aitupu_RemittanceAndBankAccountsRels', $Data); 
	}
	
    function get_In_Id($Ids)
    {
		$this->db->where_in('Id', $Ids);
        $query = $this->db->get('aitupu_RemittanceAndBankAccountsRels');   
		return $query;
    }		
	
	function get_Name_Like($Name)
    {
		$this->db->where('IsDeled', 0); 
		$this->db->like('Name', $Name); 
        $query = $this->db->get('aitupu_RemittanceAndBankAccountsRels'); 
        return $query;
    }	

	function get_Name($Name)
    {
		$this->db->where('IsDeled', 0); 
		$this->db->where('Name', $Name); 
        $query = $this->db->get('aitupu_RemittanceAndBankAccountsRels'); 
        return $query->row();
    }	
	
	function get_Limit($limitto,$limit)
	{
		$this->db->order_by("id", "desc"); 
		$this->db->where('IsDeled', 0); 
		$query = $this->db->get('aitupu_RemittanceAndBankAccountsRels',$limit,$limitto);   
			
		return $query;
	}	

	function get_Limit_Ex($Querys,$limitto,$limit)
	{
		$this->db->order_by("id", "desc"); 
		$this->db->where('IsDeled', 0); 
		/*
				$QueryArray = (
					'Field' => $querys[1],
					'QueryType' => $querys[2],
					'FiledType' => $querys[3],
					'Value' => $this->input->post($key)
				);
		*/		
		//print_r($Querys);
		foreach($Querys as $query)
		{
			if($query['QueryType']=='Like')
				$this->db->like($query['Field'], $query['Value']); 
			else
				$this->db->where($query['Field'], $query['Value']); 
		}
		
		$query = $this->db->get('aitupu_RemittanceAndBankAccountsRels',$limit,$limitto);   
			
		return $query;
	}	
	
	function update($Id,$Data)
	{
		//$this->db->where('Id', $Id);
		$this->db->update('aitupu_RemittanceAndBankAccountsRels', $Data,"Id = ".$Id); 
	}
	
	function Add($data)
	{
		$this->db->insert('aitupu_RemittanceAndBankAccountsRels',$data); 
	}
	
	function Del($Id)
	{
		$Data = array(
			'IsDeled'=>1
		);
		$this->db->update('aitupu_RemittanceAndBankAccountsRels', $Data,"Id = ".$Id); 
	}
	
	function Count()
	{
		$this->db->where('IsDeled', 0); 
		return $this->db->count_all_results('aitupu_RemittanceAndBankAccountsRels');
	}	
}